from driver import GPIO
import utime as time
import kv
import modem

#实例化一个gpio对象
led2=GPIO()
led3=GPIO()
led2.open("MQTT_LED")
led3.open("NET_LED")
#获取记录重启次数key的值
num = int(kv.get('reboot1'))
print("reboot:",num)
#重启次数小于10就重启
if num<=10:
    #记录重启次数，然后重启
    kv.set('reboot1',str(num+1))
    time.sleep_ms(200)
    modem.reboot()
else:
    print('reboot test ok!!!!')
    #删除重启key值
    kv.remove('reboot1')
    #指示灯交替闪烁
    while True:
        #LED2亮，LED3灭
        led2.write(1)
        led3.write(0)
        print('led2')
        time.sleep(1)
        #LED2灭，LED3亮
        led2.write(0)
        led3.write(1)
        print('led3')
        time.sleep(1)    
        